package edu.jhu.cs.oose.scheduleit.dao;

import java.util.List;

import edu.jhu.cs.oose.scheduleit.util.Filter;
import edu.jhu.cs.oose.scheduleit.util.JoinStatus;
import edu.jhu.cs.oose.scheduleit.vo.Group;
import edu.jhu.cs.oose.scheduleit.vo.User;
import edu.jhu.cs.oose.scheduleit.vo.UserInfo;
/**
 * The DAO class for Group VO object.
 * @author oosegroup2
 *
 */
public interface GroupDao {
	/**
	 * Responsible for save an group object into the database
	 * @param group the group object to be saved
	 */
	public void save(Group group);
	
	/**
	 * Add the user to the group according to JoinStatus
	 * @param group the group in which the user wants to join 
	 * @param user the user who wants to join the group
	 * @param status the join status for the user
	 */
	public void addUser(Group group, User user, JoinStatus status);

	/**
	 * Delete the user from the group according to JoinStatus
	 * @param group the group which the user wants to quit 
	 * @param user user the user who wants to quit the group
	 * @param status the join status for the user
	 */
	public void deleteUser(Group group, User user, JoinStatus status);
	
	/**
	 * Remove the schedule from the database
	 * @param group the group to be removed.
	 */
	public void deleteGroup(Group group);
	
		
	/**
	 * Get the groups which are fulfill with the given condition from whole database.
	 * By assigning offset and limit, the method would return a part of of the fulfilled result
	 * @param filters the search condition
	 * @param offset it's the number to skip. If offset = 0, the return object is start from the first object. 
	 *             <br> If offset =1, the return object is start from the second object.
	 * @param limit it's the maximum return size. If limit <0 , means no limitation.
	 * @return a list of group
	 */
	public List<Group> getGroup(List<Filter> filters, int offest, int limit);

	/**
	 * Calculate how may groups which are fulfill with the given condition from whole database.
	 * @param filters The search condition
	 * @return The number of how many groups satisfying the given conditions 
	 */
	public int countGroup(List<Filter> filters);
	/**
	 * Retrieve the group with certain id
	 * @param groupID	The id of the objective group
	 * @return	The group with certain id and hosted by certain user
	 */
	public Group getGroup(int groupID);
	
	/**
	 * Get the users which are fulfill with the given condition.
	 * By assigning offset and limit, the method would return a part of of the fulfilled result
	 * @param group the group to which users belong.
	 * @param status the join status. It could be ALL, APPLIED, JOINED
	 * @param offset it's the number to skip. If offset = 0, the return object is start from the first object. 
	 *             <br> If offset =1, the return event is start from the second event.
	 * @param limit it's the maximum return size. If limit <0 , means no limitation.
	 * @return a list of users
	 */
	public List<UserInfo> getUser(Group group, JoinStatus status, int offset, int limit);
	/**
	 * Calculate how many users of certain type, belonged to a given group
	 * @param group	The group to which users belong.
	 * @param status	the join status. It could be ALL, APPLIED, JOINED
	 * @return	The number of how many users satisfying the given conditions
	 */
	
	public int countUser(Group group, JoinStatus status);
	
	/**
	 * Check if the user has joined the group 
	 * @param group the group which the user may joined
	 * @param user the user to query
	 * @return true if the user has joined, otherwise, false.
	 */
	public boolean isJoined(Group group, User user);
	
	/**
	 * Check if the user has applied the group 
	 * @param group the group which the user may applied
	 * @param user the user to query
	 * @return true if the user has applied, otherwise, false.
	 */
	public boolean isApplied(Group group, User user);
	
	/**
	 * Check if the user has been denied by the group 
	 * @param group the group which the user may been denied
	 * @param user the user to query
	 * @return true if the user has been denied, otherwise, false.
	 */
	public boolean isDenied(Group group, User user);
	
}
